list=[eval(x)for x in input().split()]
l=list[0]
m=list[1]
list1=[]
i=0
while i<m:
    temp=[eval(x)for x in input().split()]
    list1.append(temp)
    i+=1
tree=[]
i=0
while i<l+1:
    tree.append(1)
    i+=1
i=0
while i<m:
    start=list1[i][0]
    end=list1[i][1]
    while start<end+1:
        tree[start]=0
        start+=1
    i+=1
trees=sum(tree)
print(trees)
    